﻿using FarmSmartSleep.Common.Domain.BeginTable;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Common.Infrastructure;
using MediatR;

namespace FarmSmartSleep.Organ.API.Application.SleepInfoCommands.SelectRecord
{
    public class VarietySearchHandler : IRequestHandler<VarietySearchCommand, Result>
    {
        private readonly IBaseRepository<Variety> varietybaseRepository;

        public VarietySearchHandler(IBaseRepository<Variety> varietybaseRepository)
        {
            this.varietybaseRepository = varietybaseRepository;
        }
        /// <summary>
        /// 品种下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Result> Handle(VarietySearchCommand request, CancellationToken cancellationToken)
        {
            var result=new Result() { Code=(int)CodeEnum.search};
            var list=varietybaseRepository.GetAll().ToList();
            result.Data=list;
            return result;
        }
    }
}
